/**
 * Created by lsx on 2017/5/8.
 */

define(['jquery','mui'], function ($,Mui) {
    document.querySelectorAll('.btn-buy')[0].addEventListener('tap', function (e) {
        $.ajax({
            type: "POST",
            url:buy_submit_url,
            data:{},// 要提交的表单
            success: function(res) {
                if(res.success== false){
                    if(res.url){
                        mui.toast(res.message);
                        setTimeout("window.location.href='"+res.url+"'",1000);
                        return;
                    }
                    Mui.alert(res.message);
                }
                if(res.success){
                    Mui.toast('下单成功');
                    var url=redirect_url+"/order_id/"+res.data.order_id;
                    console.log(url);
                    setTimeout("window.location.href='"+url+"'",1000)

                    // setTimeout("window.location.href=redirect_url",1000)
                }

            }
        });

    })
});